package net.jalbum.filters;

import java.awt.event.ActionEvent;

import javax.swing.ImageIcon;
import javax.swing.JButton;

import se.datadosen.jalbum.Msg;

public class FlipControl extends FilterControl{
	/**
	 *
	 */
	private static final long serialVersionUID = -8762814379216308341L;
	protected FlipFilterPlugin flipFilterPlugin;
	protected JButton flipVertically;
	protected JButton flipHorizontally;

	public FlipControl(){}

	public FlipControl(FlipFilterPlugin flipFilterPlugin) {

		init(flipFilterPlugin);

		addFlipControls();

	}

	protected void init(FlipFilterPlugin flipFilterPlugin) {
		this.flipFilterPlugin = flipFilterPlugin;

		super.init(flipFilterPlugin);
	}

	public void addFlipControls(){
		//Create UI-elements
        ImageIcon icon = new ImageIcon(this.getClass().getResource("res/flip-horizontal.png"));
        ImageIcon icon2 = new ImageIcon(this.getClass().getResource("res/flip-vertical.png"));
		flipVertically = new JButton(Msg.getString(this,"filters.flip.flipVertically"),icon2);
		flipHorizontally = new JButton(Msg.getString(this,"filters.flip.flipHorizontally"),icon);


		flipVertically.addActionListener(this);
		flipHorizontally.addActionListener(this);

		this.add(flipHorizontally);
		this.add("br",flipVertically);
	}

	public void actionPerformed(ActionEvent e) {
		super.actionPerformed(e);

		if (e.getSource()== flipVertically){
			flipFilterPlugin.flipVertically();
		}else if (e.getSource()== flipHorizontally){
			flipFilterPlugin.flipHorizontally();
		}

	}
}
